import Vue from 'vue'
import $message from './myMessage/myMessage'

const CreateMessage = Vue.extend($message)

const instance = new CreateMessage({
    el: document.createElement('div')
})


instance.show = false

const $toast = {
    show(msg) {
        document.body.appendChild(instance.$el)
        instance.show = true
        instance.msg = msg
    },

    hide() {
        instance.show = false
    }
}


export default {
    install() {
        if(!Vue.$toast) {
            Vue.$toast = $toast
        }
        Vue.mixin({
            created() {
                this.$toast = Vue.$toast
            }
        })
    }
}